
// 需要 调用 SharedPreferencesBaseUtils.getInstance() 在程序入口初始化.

import 'package:flutter_base_library/utils/sharedPreference/SharedPreferencesBaseUtil.dart';

class SPUtils {
  static Future<bool> saveTokenStr(String value) {

    return SharedPreferencesBaseUtils.putString('key_token_code', value);
  }

  static String getTokenStr() {
    return SharedPreferencesBaseUtils.getString('key_token_code');
  }

  static Future<bool> removeTokenStr() {
    return SharedPreferencesBaseUtils.remove('key_token_code');
  }

  ///主题
  static Future<bool> saveThemeIndex(int value) {
    return SharedPreferencesBaseUtils.putInt('key_theme_color', value);
  }

  static int getThemeIndex() {
    return SharedPreferencesBaseUtils.getInt('key_theme_color');
  }

  ///语言
  static Future<bool> saveLocale(String locale) {
    return SharedPreferencesBaseUtils.putString('key_locale', locale);
  }

  static String getLocale() {
    return SharedPreferencesBaseUtils.getString('key_locale');
  }

  ///是否同意隐私协议
  static Future<bool> saveIsAgreePrivacy(bool isAgree) {
    return SharedPreferencesBaseUtils.putBool('key_agree_privacy', isAgree);
  }

  static bool isAgreePrivacy() {
    return SharedPreferencesBaseUtils.getBool('key_agree_privacy');
  }

  ///昵称
  static Future<bool> saveNickName(String nickName) {
    return SharedPreferencesBaseUtils.putString('key_nickname', nickName);
  }

  static String getNickName() {
    return SharedPreferencesBaseUtils.getString('key_nickname');
  }

  ///是否已登陆
  static bool isLogined() {
    String nickName = getNickName();
    return nickName != null && nickName.isNotEmpty;
  }
}
